package com.barneyx.mshinfoplatform.util;

import com.barneyx.mshinfoplatform.entity.admin.AdminUserEntity;
import com.barneyx.mshinfoplatform.entity.enums.EEventType;
import com.barneyx.mshinfoplatform.entity.info.InfoEntity;
import com.barneyx.mshinfoplatform.event.MshEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class EventUtil {
    @Resource
    private ApplicationContext applicationContext;

    /**
     * 信息平台用户发布或是修改信息触发事件
     *
     * @param eventType
     * @param info
     */
    public void SendInfoAuditEvent(EEventType eventType, InfoEntity info) {
        applicationContext.publishEvent(new MshEvent<>(eventType, info));
    }


    /**
     * 后台管理员登陆触发事件
     *
     * @param eventType
     * @param adminUser
     */
    public <T> void AdminManageEvent(EEventType eventType, T adminUser) {
        applicationContext.publishEvent(new MshEvent<>(eventType, adminUser));
    }

}
